package com.ifast;

import com.ifast.common.dao.DictDao;
import com.ifast.common.domain.DictDO;
import com.ifast.common.service.DictService;
import com.ifast.common.service.impl.DictServiceImpl;
import com.ifast.common.utils.DicSet;
import com.ifast.common.utils.SpringContextHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.ServletContext;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
    private static Logger log = LoggerFactory.getLogger(ApplicationStartup.class);
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        log.info("容器初始化或者刷新时触发该事件,执行一次");
        try {
            // 字典
            log.info("________________获取已注入bean示例_______________");
            DictDao dicMgr = event.getApplicationContext().getBean(DictDao.class);
            log.info("________________获取示例结束_______________");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}